package web; // erro em todos as class... arrumar o caminho do JRE --> Propriteis --> Java Build Patch --> Libraries --> "JRE System Library" selecionar "Alternate" 

import gerenciador.Empresa;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collection;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.EmpresaDAO;

@WebServlet(urlPatterns="/busca")
public class BuscaEmpresa extends HttpServlet{
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {

		PrintWriter writer = resp.getWriter();
		writer.println("<html><body>");
		writer.println("<br>Resultado da busca: <br/>");

		String filtro = req.getParameter("filtro");
		
		Collection<Empresa> empresas = new EmpresaDAO().buscaPorSimilaridade(filtro);

		writer.println("</lu>");		
		
		for (Empresa empresa : empresas) {
			
			writer.println("<li>"+empresa.getId()+":"+empresa.getNome()+"</li>");
			
		}
		writer.println("</lu>");		
		writer.println("</body></html>");
		
	}
	
}
